package datastructre;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("zfl","qy");
        map.put("qiny","zfl");
        map.put("123","abc");
        //数据类型可以省略
        map.forEach((key,value)-> System.out.println(key+"="+value));



//        Set<String> keys = map.keySet();
//        for (String key : keys) {
//            System.out.println(key);
//        }
//        Iterator<String> it = map.keySet().iterator();
//        while(it.hasNext()) {
//            System.out.println(map.get(it.next()));
//        }
//        keys.forEach(key-> System.out.println(map.get(key)));
//        Set<Map.Entry<String,String>> entries =  map.entrySet();
//        for (Map.Entry<String, String> entry : entries) {
//            //通过entry获取key and value
//            String key = entry.getKey();
//            String value = entry.getValue();
//            System.out.println(key+" = "+value);
//        }
//
//        entries.forEach(a-> System.out.println(a.getKey()+"="+a.getValue()));

    }

}
